import 'package:flutter/cupertino.dart';
import 'package:kmxy_base/tree_select/tree_select_multiple_view.dart';
import 'package:kmxy_base/tree_select/tree_select_single_view.dart';

class TreeSelectFactory {
  static treeSelectMultipleView(
    BuildContext context, {
    required String childrenKey,
    required String idKey,
    required String valueKey,
    required List dataList,
    required String dataJson,
    required TreeSelectMultipleDataFun onConfirm,
    String? initSelect,
    bool expand = false,
    Function? onCancel,
  }) {
    showCupertinoModalPopup(
        context: context,
        builder: (builder) {
          return TreeSelectMultipleView(
            childrenKey: childrenKey,
            idKey: idKey,
            valueKey: valueKey,
            dataList: dataList,
            dataJson: dataJson,
            initSelect: initSelect ?? '',
            onConfirm: onConfirm,
            expand: expand,
            onCancel: onCancel,
          );
        });
  }

  static treeSelectSingleView(
    BuildContext context, {
    required String childrenKey,
    required String idKey,
    required String valueKey,
    required List dataList,
    required TreeSelectSingleDataFun onConfirm,
    bool expand = true,
    bool selectParent = false,
    Function? onCancel,
  }) {
    showCupertinoModalPopup(
        context: context,
        builder: (builder) {
          return TreeSelectSingleView(
            childrenKey: childrenKey,
            idKey: idKey,
            valueKey: valueKey,
            dataList: dataList,
            onConfirm: onConfirm,
            expand: expand,
            selectParent: selectParent,
            onCancel: onCancel,
          );
        });
  }
}
